iPaaS文档库 iPaaS文档库
00 概述
01 产品安装指南
02 快速入门指南
03 Studio使用指南
04 iPaaS使用指南
05 高级配置指南
06 接口服务说明
07 升级&数据迁移指南
08 产品集成指南
09 FAQ
  • ESB Server 和 iPaaS Portal 进行k8s容器化部署。
  • 1.ESB Server容器化部署
  • 1.1 上传JDK和数据库驱动包
  • 1.2 编写Dockerfile
  • 1.3 构建镜像
  • 1.4.部署ESB Server镜像到K8s
  • 1.4.1.上传镜像到私有镜像库(可选)
  • 1.4.2.创建esb-server.yml
  • 1.4.5.部署服务
  • 1.4.5.2.查看日志
  • 2.iPaaS Portal容器化部署
  • 2.1 上传JDK和数据库驱动包
  • 2.2 编写Dockerfile
  • 2.3.2.构建镜像
  • 2.4.部署iPaaS-Portal镜像
  • 2.4.1.上传镜像到私有镜像库(可选)
  • 2.4.2.创建iPaaS-Portal.yml
  • 2.4.5.部署服务
  • 2.4.5.1.部署
  • 2.4.5.2.查看日志

# ESB Server 和 iPaaS Portal 进行k8s容器化部署。

1. 本文档只提供按照以下操作方案实现k8s容器化部署相关配置参考示例, 生产环境有其他部署需求,请根据具体情况适配。

基础镜像不包含JDK,数据库驱动,以及必要的ip地址并未设置,不是一个可直接使用的镜像包。因此,需要根据实际使用情况,设置JDK路径,数据库驱动包,必要的IP之后,才可以使用。

# 1.ESB Server容器化部署

# 1.1 上传JDK和数据库驱动包

这里以jdk1.8,和mysql数据驱动作为示例,将其上传至服务器指定目录,如:/home/esb目录下。

# 1.2 编写Dockerfile

在esb目录下创建并编写Dockerfile文件,Dockerfile文件内容如下:

FROM centos:latest
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ADD ./{{ $themeConfig.package_name_prefix }}ESB_Server.tar     /opt/Primeton_ESB_Server/
COPY ./mysql-connector-java-5.1.45.jar /opt/Primeton_ESB_Server/server/libs/ 
COPY ./jdk1.8/ /opt/jdk1.8/ 
ENV RP_JAVA_HOME=/opt/jdk1.8/ 
ENTRYPOINT /opt/Primeton_ESB_Server/startServer.sh 

# 1.3 构建镜像

进入到/home/esb目录,执行以下命令:

docker build -t esb-server-image:V1 ./

至此,镜像构建完成。

# 1.4.部署ESB Server镜像到K8s

# 1.4.1.上传镜像到私有镜像库(可选)

使用如下命令,将1.3中构建成功的镜像,上传至私有镜像库中

tag制作:  docker tag esb-server-image:V1  192.168.16.221:9800/esb-server-image:V1 
推送至私有仓库: docker push 192.168.16.221:9800/esb-server-image:V1 

# 1.4.2.创建esb-server.yml

创建一个名为esb-server.yml文件,内容如下,

---
        apiVersion: v1
        kind: Service
        metadata:
          name: esb-server-svc
          namespace: primeton-poc
        spec:
          type: NodePort
          ports:
            - name: pas
              protocol: TCP
              nodePort: 30001
              port: 7007
              targetPort: 7007
            - name: http
              protocol: TCP
              nodePort: 30002
              port: 9999
              targetPort: 9999
          selector:
            app: esb-serve
        ---
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: esb-serve
          namespace: primeton-poc  
        spec:
          replicas: 1
          selector:
            matchLabels:
              app: esb-serve
          strategy:
            type: Recreate
          template:
            metadata:
              labels:
                app: esb-serve
            spec:
              nodeName: node03
              containers:
                - name: esb-serve
                  image: esb-server-image:V1
                  imagePullPolicy: IfNotPresent
                  ports:
                    - containerPort: 7007
                    - containerPort: 9999
                  volumeMounts:
                    - name: conf-volume
                      mountPath: "/opt/Primeton_APIGateway_Server/server/conf"
                    - name: log-volume
                      mountPath: "/opt/Primeton_APIGateway_Server/server/logs"
                    - name: eos-volume
                      mountPath: "/opt/Primeton_APIGateway_Server/server/EOS/_srv"
              volumes:
                - name: eos-volume
                  hostPath:
                    path: /home/primeton/poc/esb-serve-eos
                    type: DirectoryOrCreate
                - name: conf-volume
                  hostPath:
                    path: /home/primeton/poc/esb-serve-conf
                    type: DirectoryOrCreate
                - name: log-volume
                  hostPath:
                    path: /home/primeton/poc/esb-serve-log
                    type: DirectoryOrCreate

# 1.4.5.部署服务

1.4.5.1.部署 可以在部署的时候,根据实际需要修改,部署示例:

kubectl apply -f  esb-server.yml

# 1.4.5.2.查看日志

部署完成后,可以查看pod日志,确保部署后,服务启动成功,先找到部署的pod,再查看日志

#获取pod  service
kubectl get pod,svc -n primeton-poc

#查看日志
kubectl logs ${pod-name}

# 2.iPaaS Portal容器化部署

# 2.1 上传JDK和数据库驱动包

这里以jdk1.8,和mysql数据驱动作为示例,将其上传至服务器指定目录,如:opt/source/下。

# 2.2 编写Dockerfile

在source目录下创建并编写Dockerfile文件,Dockerfile文件内容如下:

#基础镜像名:标签
FROM centos:latest
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
ARG WORKDIR="/opt/governor/"
COPY ./mysql-connector-java-5.1.45.jar /opt/governor/lib/
COPY ./jdk1.8/ /opt/jdk1.8/
ENV PATH=$PATH:/opt/jdk1.8/bin
WORKDIR ${WORKDIR}
#执行启动脚本   根据介质和容器里的启动脚本进行修改
ENTRYPOINT /opt/governor/bin/startup.sh

# 2.3.2.构建镜像

进入到source目录,执行以下命令:

docker build -t esbPortal-image:V1 ./

至此,镜像构建完成。

# 2.4.部署iPaaS-Portal镜像

# 2.4.1.上传镜像到私有镜像库(可选)

使用如下命令,将2.3.2中构建成功的镜像,上传至私有镜像库中

#tag制作
docker tag esbPortal-image:V1 192.168.16.221:9800/esbPortal-image:V1

#推送至私有仓库
docker push 192.168.16.221:9800/esbPortal-image:V1

# 2.4.2.创建iPaaS-Portal.yml

创建一个名为application.yml文件,示例内容如下,根据实际情况,修改配置

---
apiVersion: v1
kind: Service
metadata:
  name: esb-console-svc
  namespace: primeton-poc
spec:
  type: NodePort
  ports:
    - protocol: TCP
      nodePort: 30000
      port: 29091
      targetPort: 29091 
  selector:
    app: esb-console
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: esb-console
  namespace: primeton-poc  
spec:
  replicas: 1
  selector:
    matchLabels:
      app: esb-console
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: esb-console
    spec:
      nodeName: node03
      containers:
        - name: esb-console
          image: iPaaS-Portal-image:V1
          command:
            [
            
              "sh",
              "-c",
              "sh  bin/startup.sh",
            ]
          imagePullPolicy: IfNotPresent          
          ports:
            - containerPort: 29091
          volumeMounts:
            - name: conf-volume
              mountPath: "/opt/governor/config"
            - name: logs-volume
              mountPath: "/opt/governor/logs"
      volumes:
        - name: logs-volume
          hostPath:
            path: /home/primeton/poc/esb-console-logs
            type: DirectoryOrCreate
        - name: conf-volume
          hostPath:
            path: /home/primeton/poc/esb-console-conf
            type: DirectoryOrCreate

# 2.4.5.部署服务

# 2.4.5.1.部署

可以在部署的时候,根据实际需要修改,部署示例:

kubectl apply -f iPaaS-Portal.yml

# 2.4.5.2.查看日志

部署完成后,可以查看pod日志,确保部署后,服务启动成功,先找到部署的pod,再查看日志

#获取pod ,svc
kubectl get pod,svc -n primeton-poc  

#查看日志
kubectl logs ${pod-name}

← 5.7 iPaaS Docker镜像说明 5.9.1 在线模型 →